/**
* @Title: CheckLoginInterceptor.java
* @Package com.yly.common.basic.interceptors
* @Description: TODO
* @author zz
* @date 2013-12-15 下午9:09:38
* @version V1.0
*/
package com.yly.common.suppor.interceptors.struts;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.opensymphony.xwork2.ActionInvocation;
import com.yly.common.basic.interceptors.struts.BasicSupportInterceptor;
import com.yly.constant.Constant;
import com.yly.module.sys.login.SysLoginAction;

/**
 * @ClassName: CheckLoginInterceptor
 * @Description: 用户登录拦截器
 * @author zz
 * @date 2013-12-15 下午9:09:38
 */
@SuppressWarnings("serial")
public class CheckLoginInterceptor extends BasicSupportInterceptor {

	protected static Log loger = LogFactory.getLog(SysLoginAction.class);
	
	@Override
	protected String beforeExecute() {
		ActionInvocation actionInvocation = this.getActionInvocation();
		Object action = actionInvocation.getAction();
		String result = null;
		if (!(action instanceof SysLoginAction)) {
			Map<String, Object> session = actionInvocation.getInvocationContext().getSession();
	        String login = (String) session.get(Constant.LOGIN_KEY);
	        result = (login != null && login.length() > 0) ? null : Constant.LOGIN_PAGE;
		}
        return result;
	}

}
